package cn.itcast.myapplication.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;

import android.os.Bundle;

import cn.itcast.myapplication.R;

public class NavViewModelDemo extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_nav_view_model);

    }


    @Override
    protected void onStart() {
        super.onStart();
        //导航控制器
        NavController controller = Navigation.findNavController(this, R.id.fragmentContainerView);

        NavigationUI.setupActionBarWithNavController(this, controller);//使用导航控制器设置操作栏

    }



    @Override
    public boolean onSupportNavigateUp() {

        NavController controller = Navigation.findNavController(this, R.id.fragmentContainerView);

        return controller.navigateUp();//顶部导航

    }


}